package fun.asgc.boot.netty.web.test1;

import fun.asgc.boot.netty.web.context.HttpRequestWrapper;
import fun.asgc.boot.netty.web.context.HttpResponseWrapper;
import fun.asgc.boot.netty.web.interceptor.RestControllerAdviceHandler;

import java.lang.reflect.Method;

/**
 *
 * @author: aoshiguchen
 * @date: 2022/7/29
 */
public class GlobalAdviceHandler implements RestControllerAdviceHandler {

	@Override
	public Object advice(HttpRequestWrapper requestParser, HttpResponseWrapper responseWrapper, String route, Method targetMethod, Object res) {
		if (res instanceof JsonResult) {
			return res;
		}
		return new JsonResult<>()
			.setCode(0)
			.setData(res);
	}

}
